<!DOCTYPE html>
<head xmlns:v-bind="http://www.w3.org/1999/xhtml" >
    <meta charset="UTF-8">
    <title>demo11事件处理</title>
  <script src="./js/vue.min.js"></script>

</head>

<body>
   <div id="app">
     <button v-on:click="greet">Greet</button>
     <a v-on:click="greet">点击我</a>
   </div>

</body>

<script type="application/javascript">
  var vm = new Vue({
    el: "#app",
    data: {
      name: "vue.js"
    },
    //在methods对象中定义
    methods: {
      greet: function (event) {
        alert("hello"+this.name+"!");
        if(event){
          alert(event.target.tagName);
        }
      }
    }
  });
  //也可以用Javascript直接调用方法
  vm.greet();
</script>
</html>
